﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace BoldBrick.SharePoint.CommonControls.DataObjects.Base
{
	public class ViewsCollection : List<BaseView>
	{
		public new void Add(BaseView view)
		{
			if ( view.IsDefault )
			{
				bool isDefaultAdded = this.Any(item => item.IsDefault);
				if ( isDefaultAdded )
					throw new ArgumentException("Only one default view could be added to collection.");
			}
			
			base.Add(view);
		}
	}
}